<script>
import popEventDetails from "@/components/interactive/popEventDetails.vue";
import popAdvertisement from "@/components/interactive/popAdvertisement.vue";
import popMappointSelection from "@/components/comm/popMappointSelection.vue";
import popParticipatingRegions from "@/components/interactive/popParticipatingRegions.vue";
import popPasswordSet from "@/components/interactive/popPasswordSet.vue";
import popContactinfo from "@/components/interactive/popContactinfo.vue";
import popOrganizerEdit from "@/components/interactive/popOrganizerEdit.vue";
import popPreviewpublishing from "@/components/interactive/popPreviewpublishing.vue";
import addPhoto from "@/components/comm/AddPhoto.vue";
import imageCropper from "@/components/comm/ImageCropper.vue";
import util from "@/js/util/Util.js";
import config from "@/js/conf/Config.js";
import editInterActive from "@/js/inieractive/EditInteractive.js";
import editActiveGoods from "@/js/inieractive/EditActiveGoods.js";
import popPrepublishing from "@/components/interactive/popPreviewpublishing.vue";

let timeout = null;
export default {
    props: [],
    components: {
        popEventDetails,
        popMappointSelection,
        popParticipatingRegions,
        popPasswordSet,
        popContactinfo,
        addPhoto,
        imageCropper,
        popOrganizerEdit,
        popPreviewpublishing,
        popAdvertisement,
		popPrepublishing,
    },
    computed: {},
	
	// watch:{
	// 	is_drawer_activity:{
	// 		handler(newValue,oldVale)
	// 		{
	// 			if(!newValue)
	// 			{
	// 				let data = {};
	// 				data.act = goods_act
	// 				editActiveGoods.update();
	// 			}
	// 		}
	// 	}
	// },
    data() {
        let validatePass = ( rule, value, callback) => {
            let isType = false;
             this.form.gd_ls.forEach( itme => {
                if (itme.mscccheckbox.length) {
                    isType = true;
                }
            })
            if (isType) {
                callback();
            } else {
                callback(new Error('请选择秒杀场次'));
            }
        };

        return {
			scrollTop:0,
            idyun: "", //云店id
            activeId: "", //活动id
            hd_type: "", //活动类型
            tool_id: "", //工具id
            activeName: "1", //tab下标
            gdactiveName: "gd1", //产品tab下标
            labelWidth: "100px", //表单单独缩进(优先级高于整体)
            labelWidthall: "80px", //表单整体缩进
            editUrl: "", //裁剪的图片
            batchid: "", //图片id
            is_drawer_good: false, //产品介绍弹框
            is_drawer_activity: false, //活动详情弹框
            is_drawer_ad: false, //广告设置弹框
            highlight_i: "", //表单高亮标识
            highlight_act: "1", //高亮的表单名称
            active_act: editInterActive.action, //EditInteractive的事件名称对象
            goods_act: editActiveGoods.action, //EditInteractive的事件名称对象
            good_info: [], //产品介绍
            good_checkList: [], //场次内要修改的产品
            cyrsxz_radio: "1", //参与人数限制选项
            kcydq_radio: "1", //可参与地区选项
            mrxgzl_radio: "1", //每人限购选项
            zfsj_radio: "1", //支付时间的选项
            zfsjxs_input: "0", //支付时间的小时
            zfsjfz_input: "0", //支付时间的分钟
            msccselect: "1", //秒杀场次
            qylogoradio: "1", //企业logo选项
            ymjztpradio: "1", //页面加载图片选项
            fxtbradio: "1", //分享图标选项
            fxnrradio: "1", //分享内容选项
			setMore:null,//活动说明
			
            form: {
                /*基础设置的字段*/
                title: "", //活动标题
                img: "", //活动图片
                info_txt: {},
                address_type: "2", //商家选址选项
                address_cp: "", //商家地址
                // address_long: "", //自定义地址(无需提交)
                kf_cellphone: "", //客服电话
                kf_wx: "", //客服微信
                kf_qq: "", //客服qq
                max_u: "0", //参与人数
                isshow_od: "1", //轮播下单信息选项
				is_buynum: "1",//是否显示已有多少人参与
                if_district: [],
                pw: {
                    //活动密码
                    isopen: "2", //活动密码选项
                    type: "2", //密码类型选项
                    v: "", //密码
                    title: "", //自定义标题
                },
                // tgylradio: "2",//推广有礼选项

                /*秒杀设置的字段*/
                paych: "1", //支付方式
                touchme: {
                    isopen: "2", //联系信息
                    type: "1", //对应产品
                    gdid_ls: [],
                }, //联系信息
                max_unum: "0", //每人限购数量
                paytime: [],
                chp_ls: [], //场次列表

                /*产品设置字段*/
                gd_ls: [],

                /*高级设置字段*/
                cpname: "", //主办单位
                iscpname2: "2", //协办单位选项
                cpname2: "", //协办单位
                isad: "2", //首屏广告
                isit: "1", //技术支持
                loading: [
                    //页面加载图片
                    {
                        url: "",
                        urls: "",
                    },
                ],
                logo: [
                    {
                        url: "", //企业logo
                        urls: "", //企业logo
                    },
                ],
				ismusic:"1",//首页是否要播放背景音乐
				music_url:"",//背景音乐地址，相对地址
                ad_ls: {//轮播图广告业
                    is_time_long: 1,
                    ad_length: 1,
                    ismusic: "1",
                    ismust: "2",
                    stype: "2",
                    time_long: "3",
                }, //首屏广告打开的默认值
                set_advc: {
                    bttn_cpname: {
                        type: "0", //主办单位点击跳转
                        type_1: {
                            link: "", //页面跳转链接
                        },
                        type_3: {
                            shopid_yd: "", //页面跳转链接
                        },
                    },
                    bttn_main: {
                        type: "0", //功能按键选项
                        type_1: {
                            //页面跳转
                            bttname: "企业官网", //按钮名称
                            typeto: "1", //跳转方式
                            type_1: {
                                link: "", //页面跳转链接
                            },
                            type_2: {
                                link: "", //小程序跳转链接
                            },
                        },
                        type_2: {
                            //一键关注
                            bttname: "关注我们", //按钮名称
                            typeto: "1", //跳转方式
                            qrcode1: [
                                {
                                    url: "",
                                    urls: "",
                                },
                            ],
                            qrcode2: [
                                {
                                    url: "",
                                    urls: "",
                                },
                            ],
                        },
                    },
                    share: {
                        isopen: "1", //分享活动
                        is2quan: "1", //分享至朋友圈
                        img: [
                            //分享图标
                            {
                                url: "",
                                urls: "",
                            },
                        ],
                        txt: "",
                    },
                },
				set_more:
				{
					info_page:[],
				},

                // 提交前转换json格式字符串
                set_skin: {
                    homePage: {
                        //首页
                        //活动未开始字体颜色
                        txt: {
							color : "#999999", //滚动字体颜色
							color0: "#FF6600", //活动未开始字体颜色
							color1: "#F04848", //活动进行中字体颜色
							color2: "#AAAAAA", //活动已结束字体颜色
                        },

                        //背景
                        bgData: {
                            bgColor: "#F5F5F5", //背景颜色
                            bgUrl: "", //绝对路径
                            baseUrl: "", //相对路径
                        },

                        //背景音乐
                        musicSrcImgData: {
                           imgOnIcon:"https://cdn.imiyun.com/d/bases/hd/defaut_btns/open-music.png", //C端b播放音乐状态图片
                           baseImgOnIcon: "d/bases/hd/defaut_btns/open-music.png",
                           imgImgOffIcon:"https://cdn.imiyun.com/d/bases/hd/defaut_btns/close-music-1.png", //C端关闭音乐状态图片
                           baseImgOffIcon: "d/bases/hd/defaut_btns/close-music-1.png",
                           left: 0, //x坐标
                           top: 0, //y坐标
                        },

                        //企业logo位置
                        cpLogoData: {
                            x: 0, //x坐标
                            y: 0, //y坐标
                        },

                        //活动说明
                        activeDesc: {
                            img: "https://cdn.imiyun.com/static/aisou/xcx/icon/icon-mh-gd.png", //绝对路径
                            baseImg: "static/aisou/xcx/icon/icon-mh-gd.png", //相对路径
                            x: 0, //x坐标
                            y: 0, //y坐标
                        },

                        //参与人数文本
                        parttakeData: {
                            txt: {
                                //文本样式
                                color: "#F04848", //文字颜色
                                size: 12, //字体大小
                                borderCol: "#FFFFFF", //描边字体颜色
                            },
                            num: {
                                color: "#3388FF", //文字颜色
                                size: 12, //字体大小
                                borderCol: "#FFFFFF", //描边字体颜色
                            },
                        },

                        // 关注我们
                        follow: {
                            color: "#FFFFFF", //字体颜色
                            bgColor: "#3388FF", //背景颜色
                        },

                        //抢购按钮
                        buyBtn: {
                           imgBtn: "https://cdn.imiyun.com/d/bases/hd/defaut_btns/buy-btn-s.png", //绝对路径
                           baseImgBtn: "d/bases/hd/defaut_btns/buy-btn-s.png", //相对路径
                           imgFinishBtn:"https://cdn.imiyun.com/d/bases/hd/defaut_btns/buy-btn-over.png", //绝对路径
                           baseImgFinishBtn:"d/bases/hd/defaut_btns/buy-btn-over.png", //相对路径
                        },
                    },
					gdListDeatail:[], //产品关注按钮皮肤
					
                    //产品详情页（产品一）
                    gdDeatailPage: {
                        txt: {
                            //产品详情字体颜色
                            //文本样式
                            color: "#F04848", //文字颜色
                            size: 12, //字体大小
                        },
                    },

                    //活动说明页
                    activeDescPage: {
                        //样式
                        color: {
                            bgColor:"#FFFFFF", //背景颜色
					        fontColor:"#333333", //字体颜色
					        pageStyle:"#F44848", //页面风格
                        },
                    },

                    //产品详情兑换
                    gdExchDeatPage: {
                        bgColor: "#3388FF",
                    },
                },
            },
            yun_list: [], //云店列表
            seckillOptions: [], //秒杀场次选项
            appletpath_data: ["/pages/index/index"], // 页面路径
            insert_data: [
                {
                    id: "1",
                    title1: "用户名称",
                    title2: "$uname",
                },
                {
                    id: "2",
                    title1: "参与人数",
                    title2: "$num_user",
                },
            ],
            copywriting_data: [
                {
                    id: "1",
                    title: "女人帮.美容养生头疗SPA(朗悦店)礼品大派送，机会难得，错过这个村可就没这个店了，你也赶紧来参加吧！",
                },
                {
                    id: "2",
                    title: "周边的朋友都赢了大奖拿回家，就剩你了！！",
                },
                {
                    id: "3",
                    title: "玩了女人帮.美容养生头疗SPA(朗悦店)的活动才发现中奖原来如此容易，你也来尝试一下吗",
                },
            ],
            recommend_title: [
                {
                    title1: "XXX活动赢大奖",
                    title2: "活动赢大奖",
                },
                {
                    title1: "XXX豪礼大放送",
                    title2: "豪礼大放送",
                },
                {
                    title1: "XXX邀您赢(可填入最大奖品名称)",
                    title2: "邀您赢(可填入最大奖品名称)",
                },
                {
                    title1: "XXX(可填入最大奖品名称)大奖等你领",
                    title2: "(可填入最大奖品名称)大奖等你领",
                },
                {
                    title1: "XXX金秋拼购节",
                    title2: "金秋拼购节",
                },
            ],
			
			gdNameArr:['产品一','产品二','产品三','产品四','产品五','产品六','产品七','产品八','产品九'],

            weekData: [
                {
                    id: "1",
                    name: "周一",
                },
                {
                    id: "2",
                    name: "周二",
                },
                {
                    id: "3",
                    name: "周三",
                },
                {
                    id: "4",
                    name: "周四",
                },
                {
                    id: "5",
                    name: "周五",
                },
                {
                    id: "6",
                    name: "周六",
                },
                {
                    id: "7",
                    name: "周日",
                },
            ],
            rules: {
                title: [
                    {
                        required: true,
                        message: "请输入活动标题",
                        trigger: "blur",
                    },
                ],
                address_cp: [
                    {
                        required: true,
                        message: "请输入地址",
                        trigger: "blur",
                    },
                ],
                kf_cellphone: [
                    {
                        required: true,
                        message: "请输入客服电话",
                        trigger: "blur",
                    },
                ],
                gd_name: [
                    {
                        required: true,
                        message: "请输入产品名称",
                        trigger: "blur",
                    },
                ],
                qty: [
                    {
                        required: true,
                        message: "请输入产品库存",
                        trigger: "blur",
                    },
                ],
                price0: [
                    {
                        required: true,
                        message: "请输入产品价格",
                        trigger: "blur",
                    },
                ],
                price: [
                    {
                        required: true,
                        message: "请输入秒杀价格",
                        trigger: "blur",
                    },
                ],
                mscccheckbox: [
                    // {
                    //     type: "array",
                    //     required: true,
                    //     message: "请选择秒杀场次",
                    //     trigger: "change",
                    // },
                    { validator: validatePass, trigger: 'blur' }
                ],
                shipp_name: [
                    {
                        required: true,
                        message: "请输入配送方式",
                        trigger: "blur",
                    },
                ],
                address_long: [
                    {
                        required: true,
                        message: "请输入取货地址",
                        trigger: "blur",
                    },
                ],
                tips: [
                    {
                        required: true,
                        message: "请输入操作提示",
                        trigger: "blur",
                    },
                ],
            },
        };
    },
    created() {
        this.activeId = this.$geturl().hdongid || "";
        this.idyun = this.$geturl().idyun || "";
        this.hd_type = this.$geturl().hd_type || "";
        this.tool_id = this.$geturl().tool_id || "";
        this.initData();
    },
    mounted() {
        uni.$on("interactive_cursor", (data) => {
            this.interactEidt(data); //执行数据
        });
        uni.$on("interactive_goods_cursor", (data) => {
            this.interactgoodEidt(data); //执行数据
        });
		
		this.$nextTick(() => {
			window.addEventListener('scroll', this.onScroll,true);
		})
    },
    methods: {
		bmapText (e) {
			this.form.address_cp = e;
		},
		gdidlsChange (e) {
            this.form.touchme.gdid_ls = e;
        },  
        initData() {
            this.setoptionsData();
            this.getYdlistFun();
            this.gethdInfoFun();
        },
        setHighlight() {
            this.highlight_i = "";
            this.form.gd_ls.map((v) => {
                v.highlight_i = "";
            });
        },
		
        // 左侧页面通信事件（EditInteractive进入）
        interactEidt(data) {
            const act = editInterActive.action;
			if(data.act === act.editActiveSet)//背景音乐
			{
				this.form.ismusic = data.data.ismusic;
				this.form.music_url = data.data.music_url;
			}
            else if (data.act === act.editActiveEnterPw) {
                this.activeName = "1";
            }
            else if (data.act === act.editActiveTitle) {
                this.activeName = "1";
            }
           else  if (data.act === act.adverPagePic 
				|| data.act === act.adverPageJumpTime 
				|| data.act === act.editCpLogo 
				|| data.act === act.editFlowBtnContext
				|| data.act === act.editShareTitle
				|| data.act === act.edidShareContext
				|| data.act === act.edidShareImg)
			{
                this.activeName = "4";
            }
            else if (data.act === act.editActiveEnterPwTit) {
                this.form.pw.title = data.data;
            }
			else if(data.act == act.edidDescripTxtContext)//活动说明描点定位
			{
				if(data.data.code == "info_time") //活动时间编辑
				{
					this.activeName = "2";
				}
				else if(data.data.code == act.editCompanyName || data.data.code == "info_cpname2" || data.data.code == 'info_it') //
				{
					this.activeName = "4";
				}
				else if(data.data.code == "info_txt")
				{
					this.activeName = "1";
				}
				data.act = data.data.code;  
			}
			else if(data.act == act.editCompanyName)
			{
				this.activeName = "4";
			}
			
			else if(data.act == act.mainBannerPic) //首页图片
			{
				this.form.img = data.data.baseUrl;
			}
			else if(data.act == act.editMusicIcon) //音乐关闭，打开按钮
			{
				this.form.set_skin.homePage.musicSrcImgData = data.data;
			}
			else if(data.act == act.editGoodsTitle  //产品详情
				|| data.act == this.active_act.editGoodsTitle1
				|| data.act == this.active_act.editGoodsChangeDate
				|| data.act == this.active_act.editGoodsCouponsChange
				|| data.act == this.active_act.editGoodsCouponsUseTime
				|| data.act == this.active_act.editGoodsChangeAdress
				|| data.act == this.active_act.editGoodsChangeMustKnow
				|| data.act == this.active_act.editSeviceCellphone
				|| data.act == this.active_act.editMakeCompanyDesc
				|| data.act == this.active_act.editKnowMore)//
			{
				this.activeName = "3";
			}
			
			else if(data.act == act.editGdLsImg) //产品图片
			{
				this.form.gd_ls.forEach((s)=>{
					if(s.id == data.goodsId)
					{
						s.img = data.baseUrl;
					}
				});
			}
			else if(data.act == act.editMoveUpGd || data.act == act.editMoveDownGd)//向上移动产品 ,向下移动产品
			{
				let nextIdx = data.act == act.editMoveUpGd ? data.data.index - 1 : data.data.index + 1;
				
				this.form.chp_ls.forEach((s)=>{
					if(s.chpno == data.data.chpno)
					{
						let temp = s.gd_list[data.data.index];
						s.gd_list[data.data.index] = s.gd_list[nextIdx];
						s.gd_list[nextIdx] = temp;
						let gStr = "";
						s.gd_list.forEach((s)=>{
							if(gStr == "")
							{
								gStr = s.id;
							}
							else
							{
								gStr = gStr + "," + s.id;
							}
						})
						s.gdid_str = gStr;
						console.log("s.gdid_str=======================:",s.gdid_str);
					}
				})
				this.$forceUpdate();
			}
			if(data.act == act.edidDescripTxtMoveUp || data.act ==  act.edidDescripTxtMoveDown)
			{
				this.form.set_more.info_page = data.data;
			}
			if(data.act == act.editActiveTxtSty)
			{
				this.form.set_skin.homePage.txt = data.data;
			}
			if(data.act == act.eidtBuyGdBtn)
			{
				this.form.set_skin.homePage.buyBtn = data.data;
			}
			if(data.act == act.editActiveBg)
			{
				this.form.set_skin.homePage.bgData = data.data;
			}
			if(data.act == act.mainParttStyle)
			{
				this.form.set_skin.homePage.parttakeData = data.data;
			}
			if(data.act == act.editGoodsDetailsBg)
			{
				this.form.set_skin.gdExchDeatPage = data.data;
			}
			if(data.act == act.mainBuyTipTxt)
			{
				this.form.isshow_od = data.data ? '1':'2';
			}
			if(data.act == act.mainParttTxt)
			{
				this.form.is_buynum = data.data ? '1':'2';
			}
			
            this.highlight_i = data.act;
			if(this.highlight_i)
				this.jump();
        },
		
		inputGdInfo(data)
		{
			this.form.chp_ls.forEach(s=>{
				s.gd_list.forEach(c=>{
					if(c.gd_pos == data.data.gd_pos)
					{
						c.gd_name = data.data.gd_name;
					}
				});
			});
			editInterActive.update(data);
		},
		
        // 左侧页面通信事件（EditInteractive出去）
        sendoutEidt(actval) {
            const act = this.active_act;
            const f = JSON.parse(JSON.stringify(this.form));
            let data = { act: actval };
            if (actval === act.adverPagePic) {
                // 广告
                f.ad_ls.imgs = [];
                f.ad_ls.img.map((v) => {
                    if (v.img[0].url) {
                        f.ad_ls.imgs.push(v.img[0].url);
                    }
                });
                f.ad_ls.time_long =
                    f.ad_ls.is_time_long == 2 ? 0 : f.ad_ls.time_long;
                data.data = f.ad_ls;
            } else if (actval === act.editActiveTitle) {
                // 活动标题
                data.data = f.title;
            } else if (actval === act.editCpLogo) {
                // 企业logo
                data.data = f.logo[0].url;
            } else if (actval === act.editFlowBtnContext) {   // 功能按钮
				data.data = f.set_advc.bttn_main['type_'+f.set_advc.bttn_main.type] ? f.set_advc.bttn_main['type_'+f.set_advc.bttn_main.type].bttname : "功能按钮未开启";
            }
			else if(actval == act.edidShareContext)//分享内容
			{
				data.data = this.form.set_advc.share.txt;
			}
			else if(actval == act.edidShareImg)//分享icon图标
			{
				data.data = this.form.set_advc.share.img[0].url;
			}
            editInterActive.update(data);
        },
		
        // 左侧页面通信事件（EditActiveGoods进入）
        interactgoodEidt(datas) {
            const act = editActiveGoods.action;
            const data = JSON.parse(JSON.stringify(datas));
            this.activeName = "3";
            console.log(data, "收到");
            if (data.data.type == 1) {
                if (data.act == act.editGoodsSpwerPic) {
                    // 产品轮播图
                    data.data.img.map((v, i) => {
                        if (!v.img_url) {
                            data.data.img.splice(i, 1);
                        }
                    });
                    this.form.gd_ls.map((v) => {
                        if (v.gd_pos === data.data.gd_pos) {
                            v.img = data.data.img;
                        }
                    });
                } else if (data.act == act.editGoods) {
                    this.gdactiveName = data.data.gd_pos;
                }
				this.updateGdInfo();
            } 
			else if(data.type == 1)
			{
				this.gdactiveName = data.data;
			}
			else if(data.act == act.editGoodsFlowBtnStyle)
			{
				this.form.set_skin.gdListDeatail.forEach((s)=>{
					if(s.gd_pos == this.gdactiveName)
					{
						s.follow.color = data.data.color; //字体颜色
						s.follow.bgColor = data.data.bgColor;//背景颜色
					}
				})
			}
			else {
				this.highlight_i = data.act;
            }
			// this.onScroll();
			if(this.highlight_i)
				this.jump();
        },
		//更新产品详情，产品副标题客服电话,可用时间
		updateGdInfo()
		{
			uni.$emit(this.goods_act.addsetGoods, this.form.gd_ls,this.gdactiveName);
		},
		
		//更新产品操作提示
		updateTips(item,txt)
		{
			item.set_gd_init.onoff_line_1.tips = txt;
			this.updateGdInfo();
		},
		
		//兑换开始时间，兑换结束时间
		updateStartTime(item,type)
		{
			if(type == 0)
			{
				item.set_gd_init.onoff_line_1.outday_ch.time_from = util.format(item.set_gd_init.onoff_line_1.outday_ch.time_from);
			}
			else
			{
				item.set_gd_init.onoff_line_1.outday_ch.time_to = util.format(item.set_gd_init.onoff_line_1.outday_ch.time_to);
			}
			this.updateGdInfo();
		},
		
		//更产品关注按钮样式
		updateGdFollowBtn(data)
		{
			editInterActive.update(data);
		},
		
        // 左侧页面通信事件（EditActiveGoods出去）
        sendoutgoodEidt(actval) {
            const act = this.goods_act;
            if (actval === act.editGoodsDesc) {
				let data = {};
				data.act = actval;
				data.data = this.good_info;
				editActiveGoods.update(data);
            }
        },
		
        // 更改兑换方式
        shippTypeChe(item, data) {
            if (item.indexOf("1") > -1 && item.length == 1) {
                data.shipp_name = "上门自取";
            } else if (item.indexOf("2") > -1 && item.length == 1) {
                data.shipp_name = "快递邮寄";
            } else if (item.length > 1) {
                data.shipp_name = "上门自取/快递邮寄";
            }
        },
		
        // 获取云店列表
        async getYdlistFun() {
            let url = config.YUN_SHOP_LS;
            let param = {};
            let res = await this.$api({ url: url, data: param });
			if(!res)return;
            if (res.status == 1 && res.data) {
                this.yun_list = res.data;
                res.data.map((v) => {
                    if (v.id == this.idyun) {
                        this.form.cpname = v.name;
                    }
                });
            }
        },
		
        /*****上传图片成功*****/
        uploadPicSuccess(index, name, result, batchid) {
            if (batchid === "enterprise_logo") {
                this.form.logo = [
                    {
                        url: result.url,
                        urls: result.name,
                    },
                ];
                this.sendoutEidt(this.active_act.editCpLogo);
            } else if (batchid === "load_img") {
                this.form.loading = [
                    {
                        url: result.url,
                        urls: result.name,
                    },
                ];
            } else if (batchid === "share_icon") {
                this.form.set_advc.share.img = [
                    {
                        url: result.url,
                        urls: result.name,
                    },
                ];
				 this.sendoutEidt(this.active_act.edidShareImg);
            } else if (batchid === "follow_qr") {
                if (this.form.set_advc.bttn_main.type_2.typeto == 1) {
                    this.form.set_advc.bttn_main.type_2.qrcode1 = [
                        {
                            url: result.url,
                            urls: result.name,
                        },
                    ];
					
                } else {
                    this.form.set_advc.bttn_main.type_2.qrcode2 = [
                        {
                            url: result.url,
                            urls: result.name,
                        },
                    ];
                }
            } else {
                this.form.gd_ls.map((v, i) => {
                    if (i == batchid) {
                        if (
                            v.set_gd_init.onoff_line_1.bttn.type_2.typeto == 1
                        ) {
                            v.set_gd_init.onoff_line_1.bttn.type_2.qrcode1[0].url =
                                result.url;
                            v.set_gd_init.onoff_line_1.bttn.type_2.qrcode1[0].urls =
                                result.name;
                        } else {
                            v.set_gd_init.onoff_line_1.bttn.type_2.qrcode2[0].url =
                                result.url;
                            v.set_gd_init.onoff_line_1.bttn.type_2.qrcode2[0].urls =
                                result.name;
                        }
                    }
                });
            }
        },
        /*******上传头像*******/
        uploadAavatar(data, batchid) {
            this.editUrl = data.url;
            this.batchid = batchid;
        },
        /*****确认编辑图片****/
        confirm(data) {
            if (this.batchid === "enterprise_logo") {
                this.$refs.AddPhotoLogo.confirm(data, this.uploadPicSuccess);
            } else if (this.batchid === "load_img") {
                this.$refs.AddPhotoLoadimg.confirm(data, this.uploadPicSuccess);
            } else if (this.batchid === "share_icon") {
                this.$refs.AddPhotoShareicon.confirm(
                    data,
                    this.uploadPicSuccess
                );
            } else if (this.batchid === "follow_qr") {
                this.$refs.AddPhotoFollowqr.confirm(
                    data,
                    this.uploadPicSuccess
                );
            } else {
                this.$refs.AddPhoto[this.batchid].confirm(
                    data,
                    this.uploadPicSuccess
                );
            }
        },
        //图片取消上传
        cancel() {
            if (this.batchid === "enterprise_logo") {
                this.$refs.AddPhotoLogo.cancel();
            } else if (this.batchid === "load_img") {
                this.$refs.AddPhotoLoadimg.cancel();
            } else if (this.batchid === "share_icon") {
                this.$refs.AddPhotoShareicon.cancel();
            } else if (this.batchid === "follow_qr") {
                this.$refs.AddPhotoFollowqr.cancel();
            } else {
                this.$refs.AddPhoto[this.batchid].cancel();
            }
        },
        // 点击替换按钮
        replaceImg(url, index) {
            if (index === "enterprise_logo") {
                this.$refs.AddPhotoLogo.chooseImage({ url }, 0);
            } else if (index === "load_img") {
                this.$refs.AddPhotoLoadimg.chooseImage({ url }, 0);
            } else if (index === "share_icon") {
                this.$refs.AddPhotoShareicon.chooseImage({ url }, 0);
            } else if (index === "follow_qr") {
                this.$refs.AddPhotoFollowqr.chooseImage({ url }, 0);
            } else {
                this.$refs.AddPhoto[index].chooseImage({ url }, 0);
            }
        },
        good_checkFun (item) {
            console.log(item,'good_checkFungood_checkFun')
        },
        // 确定修改场次宝贝数量
        setSessionsgoodNum(item,list) {
            // list.forEach ( i=> {
            //     item.gd_list = item.gd_list.filter (row=> {
            //         return item.gd_list.gd_pos = i;
            //     })
            // })
            if (!list.length) return this.$message.error('请选择产品');
            item.visible = false;
            let arr = [];
            this.form.gd_ls.map((v) => {
                if (this.good_checkList.indexOf(v.gd_pos) > -1) {
                    arr.push(v);
                }
            });
            
            item.gd_list = arr;
            this.setgoodSessionsSelect();
        },
        // 产品设置内场次选中的变化
        setgoodSessionsSelect() {
            this.form.gd_ls.map((v, i) => {
                v.mscccheckbox = [];
                this.form.chp_ls.map((vs) => {
                    if (vs.gd_list) {
                        vs.gd_list.map((vw) => {
                            if (vw.gd_pos === v.gd_pos) {
                                v.mscccheckbox.push(vs.chpno);
                            }
                        });
                    }
                });
            });
            console.log(this.form.gd_ls,'this.form.gd_lsthis.form.gd_ls   ')
        },
        //打开修改产品弹框
        openModifygood(gd_list) {
            this.good_checkList = [];
            gd_list.map((v) => {
                this.good_checkList.push(v.gd_pos);
            });
        },
        // 设置产品数量及字段
        setgoodList(type = 0) {
            let numlength = 0;
            if (type == 0) {
                numlength = 3; //产品初始数量
            } else if (type == 1) {
                numlength = 1;
            } else {
                numlength = 0;
            }
            if (numlength > 0) {
                // 加
				console.log("numlength====:",numlength);
                if (this.form.gd_ls.length == 10) return;
				let gdPos = "";
                for (let i = 0; i < numlength; i++) {
					let gd_pos = `gd${this.form.gd_ls.length + 1}`;
					if(numlength == 1)
						gdPos = gd_pos;
                    this.form.gd_ls.push({
                        gd_pos: gd_pos ,
                        id: `gd${this.form.gd_ls.length + 1}`,
                        gd_title: `产品${this.setNumber(
                            this.form.gd_ls.length
                        )}`,
                        qty: "", //库存
                        price0: "", //产品价格
                        price: "", //秒杀价格
                        max_unum: "5", //每人限购
                        gd_name: "", //产品名称
                        mrxgradio: 1, //每人限购选项(无需提交)
                        mscccheckbox: [], //秒杀场次的勾选(无需提交)
                        address_long: "", //自定义取货地址(无需提交)
                        tips: "", //操作提示(无需提交)
                        shipp_name: "上门自取", //配送方式输入(无需提交)
                        img: "", //产品图片
                        highlight_i: "", //产品内字段高亮
                        info: [{ img: [{ url: "", urls: "" }], txt: "" }], //图文
                        set_gd_init: {
                            shipp_name: "", //配送方式输入
                            txt_gd: "",
                            onoff_line: "1", //兑换方式

                            onoff_line_1: {
                                shipp_type: ["1"], //自取和邮寄
                                address_cp: {
                                    type: "1", //取货地址选项
                                    address_long: "", //自定义取货地址
                                },
                                tips: "", //操作提示
                                outday_ch: {
                                    type: "1", //兑换期限选项
                                    time_from: this.setbufStime(), //兑换期限开始日期
                                    time_to: this.setbufStime(), //兑换期限结束日期
                                    days: "90", //生效后有效天数
                                    days_from: "90", // 领取后生效天数
                                },
                                week_use: {
                                    type: "1", //可用时间段选项
                                    week: [], //部分可以选项
                                },
                                bttn: {
                                    type: "0", //自定义按钮选项
                                    type_1: {
                                        //页面跳转
                                        bttname: "企业官网", //按钮名称
                                        typeto: "1", //跳转方式选项
                                        type_1: {
                                            link: "", //页面跳转链接
                                        },
                                        type_2: {
                                            link: "", //小程序跳转
                                        },
                                    },
                                    type_2: {
                                        //一键关注
                                        bttname: "关注我们", //按钮名称
                                        typeto: "1", //跳转方式选项
                                        qrcode1: [
                                            //微信二维码
                                            {
                                                url: "",
                                                urls: "",
                                            },
                                        ],
                                        qrcode2: [
                                            //小程序二维码
                                            {
                                                url: "",
                                                urls: "",
                                            },
                                        ],
                                    },
                                },
                                gdname0: "", //副标题
                                phone_kf: "", //产品客服电话
                                txt_ch: "", //兑换须知
                                iscpname: "2", //主办单位介绍
                            },
                        },
                    });
                }
                if (type == 1) {
                    this.gdactiveName =
                        this.form.gd_ls[this.form.gd_ls.length - 1].gd_pos;
                }
				
				if(numlength == 1 && gdPos) //新增皮肤
				{
					
					let obj = {};
					obj.gd_pos = gdPos;
					obj.follow = {
						color: "#FFF", //字体颜色
					    bgColor: "#3388FF"//背景颜色
					};
					let has = false;
					this.form.set_skin.gdListDeatail.forEach(s=>{
						if(s.gd_pos == gdPos)
						{
							s = obj;
							has = true;
						}
					});
					if(!has)
						this.form.set_skin.gdListDeatail.push(obj);
					editActiveGoods.update({act:this.goods_act.addNewGoodsDetialSkin,data:obj}); 
					 
					this.handlegoodClick();
				}
				
            } else {
                // 减
                if (this.form.gd_ls.length == 3) return;
                let num = this.form.gd_ls.length - 1;
                this.gdactiveName = this.form.gd_ls[num - 1].gd_pos;
                this.form.gd_ls.splice(num, 1);
            }
           this.updateGdInfo();
        },
        //设置场次
        setMscclist(num) {
            if (this.form.chp_ls.length == num) return;
            if (this.form.chp_ls.length > num) {
                let numletgth = this.form.chp_ls.length - num;
                this.form.chp_ls.splice(num, numletgth);
                // 减
            } else {
                // 加
                let numletgth = num - this.form.chp_ls.length;
                for (let i = 0; i < numletgth; i++) {
					let st = this.setbufStime(0);//开始时间
					let et = this.setbufStime(1);//结束时间
                    this.form.chp_ls.push({
                        stime: st,
                        etime: et,
                        chpno: String(this.form.chp_ls.length + 1),//一定要转成字符串，要不选中不了
                        title: `场次${this.setNumber(this.form.chp_ls.length)}`,
                        status: 0,
                        status_txt: "未开始",
                        visible: false,
                        gd_list: JSON.parse(JSON.stringify(this.form.gd_ls)),
						timeArr: [st,et],
                    });
                }
            }
            this.setgoodSessionsSelect();
        },
		timestampFun (e,i) {
            if(!e || !e.length) return false;
            this.form.chp_ls[i].stime = e[0];
            this.form.chp_ls[i].etime = e[1];
        },  
        // 秒杀设置场次内的产品变化
        setSessionsgood(type, sessions, item) {
		    if (type) {
				if(!sessions.gd_list)
					sessions.gd_list = [];
				let isHas = false;
				sessions.gd_list.forEach((s)=>{
					if(s.gd_pos == item.gd_pos)
					{
						isHas = true;
					}
				});
				if(!isHas)
				{
					sessions.gd_list.push({ ...item });
					sessions.gd_list.sort((a, b) => {
						return (
							a.gd_pos.replace(/[^0-9]/gi, "") -
							b.gd_pos.replace(/[^0-9]/gi, "")
						);
					});
				}
				if(sessions.gd_list.length == 1)
				{
					this.$message.error(`请在'${sessions.title}'活动中保留一个产品!`);
				}
		    } else {
				if(sessions.gd_list.length == 1)//点击取消勾选时，已经改变了数组的值，所有要push补充
				{
					item.mscccheckbox.push(String(sessions.chpno));
					this.$message.error(`请在'${sessions.title}'活动中保留一个产品!`);
					return;
				}
				
				sessions.gd_list.map((v, i) => {
					if (v.gd_pos === item.gd_pos) {
						sessions.gd_list.splice(i, 1);
					}
				});
		    }
	    },
		
        setbufStime(type) {
            let d = new Date().getTime();
            if (type == 1) {
                d = d + 7200000; //加俩小时
            }
            return util.format(d);
        },
        // 设置字母
        setLetter(i) {
            const arr = ["A", "B", "C", "D", "E", "F", "G", "H", "I"];
            return arr[i];
        },
        // 设置中文数字
        setNumber(i) {
            const arr = [
                "一",
                "二",
                "三",
                "四",
                "五",
                "六",
                "七",
                "八",
                "九",
                "十",
            ];
            return arr[i];
        },
        // 秒杀场次选项
        setoptionsData() {
            for (let i = 1; i < 10; i++) {
                this.seckillOptions.push(i);
            }
        },
		
        // 选中tab
        handleClick() {
            if (this.activeName == 3) {
				 this.handlegoodClick();
            }
			//this.addEvent();
        },
		
        // 选中产品tab
        handlegoodClick() {
			let gd = null;
			this.form.gd_ls.forEach(s=>{
				if(s.gd_pos === this.gdactiveName)
				{
					gd = s;
				}
			});
            uni.$emit(this.goods_act.editGoods2, this.gdactiveName,gd);
        },
        // 选择标题
        setTitleFun(item) {
            this.form.title += item.title2;
            this.sendoutEidt(this.active_act.editActiveTitle);
        },
        // 插入分享变量
        setInsertFun(item) {
            if (item.id == 1) {
                this.form.set_advc.share.txt = `${item.title2}${this.form.set_advc.share.txt}`;
            } else {
                this.form.set_advc.share.txt = `${this.form.set_advc.share.txt}${item.title2}`;
            }
        },
        // 推荐文案
        setCopywritingFun(item) {
            this.form.set_advc.share.txt = item.title;
        },
        inputFocus() {
            // this.highlight_i = "HDBT";
        },
        // 打开活动详情
        openEventdetails() {
            this.is_drawer_activity = true;
        },
        opengoodEventdetails(item) {
            this.is_drawer_good = true;
            this.good_info = {
                img_txt: item.length,
                txt_arr: item,
            };
        },
        // 打开地地图选择器
        openMapFun() {
            this.$refs.popMappointSelection.initData();
			this.$refs.popMappointSelection.keyword = this.form.address_cp;
			this.$refs.popMappointSelection.search_input = this.form.address_cp;
        },
        // 打开地区选择
        openregionFun() {
            this.$refs.popParticipatingRegions.initData();
        },
        // 打开密码管理
        openPasswordFun() {
            this.$refs.popPasswordSet.initData();
        },
        // 打开联系信息设置
        openContactFun() {
            this.$refs.popContactinfo.initData();
        },
        // 打开主办单位信息编辑
        openOrganizer() {
            this.$refs.popOrganizerEdit.initData();
        },
        // 预览与发布
        previewPubFun() {
            this.saveFun("1");
        },
        // 保存
        submitFun() {
            this.saveFun("2");
        },
        // 提交数据
        async saveFun(type) {
            let numBool = 0; //为0则提交通过
            this.$refs.form.validate((valid) => {
                if (valid) {
                    for (let i = this.form.gd_ls.length; i--; i > 0) {
                        this.$refs.itemForm[i].validate((valid) => {
                            if (!valid) {
                                numBool++;
                                this.gdactiveName = `gd${i + 1}`;
                                this.activeName = "3";
                            }
                        });
                    }
                } else {
                    numBool++;
                    this.activeName = "1";
                }
            });
            if (numBool == 0) {
                const data = this.getSubmitData();
                // console.log("原始的", this.form);
                // console.log("格式后", data);
                // console.log("json", JSON.stringify(data));
				// console.log("data====:",data);
				// return;
                let url = config.HD_MS_HDONG_HD_SAVE;
                let param = data;
                let res = await this.$api({ url: url, data: param });
                if (!res) return;
                if (res.status == 1) {
                    if (type == 1) {
						let Obj = {
							id: res.data.hdongid,
							shopid_yd: this.$geturl().idyun,
							hdid: this.$geturl().tool_id,
							type: this.$geturl().hd_type,
							cat_id: this.$geturl().cat_id
						}
						this.$refs.popPrepublishing.initData(Obj);
                    } else {
                        this.$msg({ title: "保存成功" });
                        setTimeout(() => {
                            this.$emit("backFun");
                        }, 1000);
                    }
                }
            }
            // const data = this.getSubmitData();
            // console.log("格式后", data);
        },
        // 格式提交的数据
        getSubmitData() {
            const f = JSON.parse(JSON.stringify(this.form));
            f.hdongid = this.activeId;
            f.hd_type = this.hd_type;
            f.tool_id = this.tool_id;
            f.idyun = this.idyun;

            // 基础设置
            if (this.kcydq_radio == 1) {
                f.if_district = [];
            }

            if (f.info_txt.type == 1) {
                f.info_txt.txt_arr = [];
            } else {
                if (f.info_txt.txt_arr) {
                    f.info_txt.txt_arr.map((v) => {
                        v.img = v.img[0].urls;
                    });
                }
            }
            f.max_u = f.max_u && this.cyrsxz_radio == 2 ? f.max_u : 0;

            // 秒杀设置
            f.max_unum = f.max_unum && this.mrxgzl_radio == 2 ? f.max_unum : 0;

            if (this.zfsj_radio == 1) {
                f.paytime = [];
            } else {
                f.paytime = [
                    this.zfsjxs_input ? this.zfsjxs_input : "0",
                    this.zfsjfz_input ? this.zfsjfz_input : "0",
                ];
            }
            f.chp_ls.map((v) => {
				if(v.gd_list)
				{
					v.gd_list.map((vs) => {
					    delete vs.mrxgradio;
					    delete vs.mscccheckbox;
					    delete vs.address_long;
					    delete vs.tips;
					    delete vs.shipp_name;
					    delete vs.set_gd_init;
					    delete vs.set_gd;
					});
				}
            });

            // 产品设置
			if(f.gd_ls)
			{
				f.gd_ls.map((v) => {
				    v.imgs = [];
				    v.max_unum = v.max_unum && v.mrxgradio == 2 ? v.max_unum : 0;
				    v.set_gd_init.onoff_line_1.address_cp.address_long =
				        v.address_long;
				    v.set_gd_init.onoff_line_1.tips = v.tips;
				    v.set_gd_init.onoff_line_1.shipp_name = v.shipp_name;
				    v.set_gd_init.onoff_line_1.bttn.type_2.qrcode1 =
				        v.set_gd_init.onoff_line_1.bttn.type_2.qrcode1[0].urls;
				    v.set_gd_init.onoff_line_1.bttn.type_2.qrcode2 =
				        v.set_gd_init.onoff_line_1.bttn.type_2.qrcode2[0].urls;
				    if (v.set_gd_init.onoff_line_1.week_use.type == 1) {
				        v.set_gd_init.onoff_line_1.week_use.week = [
				            1, 2, 3, 4, 5, 6, 7,
				        ];
				    }
				    if (f.hdongid) {
				        v.set_gd = JSON.parse(JSON.stringify(v.set_gd_init));
				        delete v.set_gd_init;
				    }
				    if (v.info) {
				        v.info.map((vs) => {
				            vs.img = vs.img[0].urls || "";
				        });
						
				    }
				    if (v.img) {
						let type = Object.prototype.toString.call(v.img)
						if(type === "[object Array]")
						{
							v.img.map((vs) => {
							    v.imgs.push(vs.img);
							});
							v.img = v.imgs.join();
						}
				    }
				    // v.img = v.imgs.join();
				
				    delete v.mrxgradio;
				    delete v.mscccheckbox;
				    delete v.address_long;
				    delete v.tips;
				    delete v.shipp_name;
				    delete v.imgs;
				});
			}

            // 高级设置
            f.ad_ls.imgs = [];
            if (f.ad_ls.img) {
                f.ad_ls.img.map((v) => {
                    if (v.img[0].urls) {
                        f.ad_ls.imgs.push(v.img[0].urls);
                    }
                });
            }

            f.ad_ls.img = f.ad_ls.imgs.join();
            f.ad_ls.time_long =
                f.ad_ls.is_time_long == 2 ? 0 : f.ad_ls.time_long;
            f.loading =
                this.ymjztpradio == 2 && f.loading[0].urls
                    ? f.loading[0].urls
                    : "";
            f.logo =
                this.qylogoradio == 2 && f.logo[0].urls ? f.logo[0].urls : "";
            f.set_advc.bttn_main.type_2.qrcode1 =
                f.set_advc.bttn_main.type_2.qrcode1[0].urls;
            f.set_advc.bttn_main.type_2.qrcode2 =
                f.set_advc.bttn_main.type_2.qrcode2[0].urls;
            f.set_advc.share.img =
                this.fxtbradio == 2 && f.set_advc.share.img[0].urls
                    ? f.set_advc.share.img[0].urls
                    : "";
            f.set_advc.share.txt =
                this.fxnrradio == 2 && f.set_advc.share.txt
                    ? f.set_advc.share.txt
                    : "";

            delete f.ad_ls.is_time_long;
            delete f.ad_ls.ad_length;
            delete f.ad_ls.imgs;

            return f;
        },

        // 获取活动详情
        async gethdInfoFun() {
            let url = config.HD_MS_HDONG_HD_INFO;
            let param = {
                hdongid: this.activeId,
                idyun: this.idyun,
            };
            let res = await this.$api({ url: url, data: param,showToast: false, });
            if (!res) return;
            if (res.status == 1) {
                const form = this.form;
                const info = res.data;
                info.chp_ls
                // 基础设置
                form.hd_type = info.hd_type;
                form.tool_id = info.tool_id;
                form.title = info.title;
                form.address_cp = info.address_cp;
                form.kf_cellphone = info.kf_cellphone;
                form.kf_wx = info.kf_wx;
                form.kf_qq = info.kf_qq;
                form.max_u = info.max_u;
                form.set_skin = info.set_skin?info.set_skin:form.set_skin;
                if (!info.info_txt) {
                    form.info_txt = {
                        type: "1",
                        txt: "",
                        img_txt: 1,
                        txt_arr: [
                            {
                                img: [
                                    {
                                        url: "",
                                        urls: "",
                                    },
                                ],
                                txt: "",
                            },
                        ],
                    };
                } else {
                    form.info_txt =
                        typeof info.info_txt === "string"
                            ? JSON.parse(info.info_txt)
                            : info.info_txt;
                    if (form.info_txt.txt_arr) {
                        form.info_txt.txt_arr.map((v) => {
                            v.img = [
                                {
                                    url: v.img_url,
                                    urls: v.img,
                                },
                            ];
                        });
                    } else {
                        form.info_txt.txt_arr = [
                            {
                                img: [
                                    {
                                        url: "",
                                        urls: "",
                                    },
                                ],
                                txt: "",
                            },
                        ];
                    }

                    form.info_txt.type = String(form.info_txt.type);
                }
                if (!info.pw) {
                    form.pw = {
                        isopen: "2",
                        type: "2",
                        v: "",
                        title: "输入活动密码后进入活动",
                    };
                } else {
                    form.pw = info.pw;//JSON.parse(info.pw);
                    form.pw.isopen = String(form.pw.isopen);
                    form.pw.type = String(form.pw.type);
                }
                if (info.if_district) {
                    this.kcydq_radio = "2";
                    form.if_district = info.if_district;
                } else {
                    form.if_district = [];
                }
                this.cyrsxz_radio = !info.max_u || info.max_u == 0 ? "1" : "2";
                form.isshow_od = String(info.isshow_od);
				
				form.is_buynum = String(info.is_buynum);

                // 秒杀设置
                if (!info.set_sell.touchme) {
                    form.touchme = {
                        isopen: "2",
                        type: "1",
                        gdid_ls: [],
                    };
                } else {
                    // form.touchme = info.set_sell.touchme;//JSON.parse(info.set_sell.touchme);
                    // console.log(form.touchme,'form.touchmeform.touchme')
					form.touchme = {
					    isopen: String(info.set_sell.touchme.isopen),
					    type:  String(info.set_sell.touchme.type),
					    gdid_ls: info.set_sell.touchme.gdid_ls ? info.set_sell.touchme.gdid_ls : [],
					};
                }
                form.max_unum = info.max_unum;
                this.mrxgzl_radio =
                    !info.max_unum || info.max_unum == 0 ? "1" : "2";
                if (!info.paytime || info.paytime.length == 0) {
                    this.zfsj_radio = "1";
                    form.paytime = [];
                } else {
                    info.paytime = Array.isArray(info.paytime)
                        ? info.paytime
                        : JSON.parse(info.paytime);
                    this.zfsj_radio = "2";
                    this.zfsjxs_input = info.paytime[0];
                    this.zfsjfz_input = info.paytime[1];
                }
                form.paych = String(info.paych);
                // form.touchme.isopen = //"1"//info.touchme ? String(info.touchme.isopen): form.touchme.isopen;
                // form.touchme.type = "1" //info.touchme ? String(info.touchme.type): form.touchme.type;
                // 产品设置
                if (param.hdongid) {
                    // 产品编辑
                    if (info.gd_ls) {
                        info.gd_ls.map((v) => {
                            form.gd_ls.push({
                                address: v.address,
                                id: v.id,
                                gd_name: v.gdname,
                                gd_title: `产品${this.setNumber(
                                    this.form.gd_ls.length
                                )}`,
                                gd_pos: v.gd_pos,
                                info: v.info,
                                img: v.img,
                                max_unum: v.max_unum,
                                price: v.price,
                                price0: v.price0,
                                qty: v.qty,
                                highlight_i: "",
                                mrxgradio:
                                    !v.max_unum || v.max_unum == 0 ? 1 : 2,
                                address_long:
                                    v.set_gd.onoff_line_1.address_cp
                                        .address_long,
                                tips: v.set_gd.onoff_line_1.tips,
                                shipp_name: v.set_gd.onoff_line_1.shipp_name,
                                tips: v.set_gd.onoff_line_1.tips,
                                set_gd_init:v.set_gd, //JSON.parse(
                                    //JSON.stringify(v.set_gd)
                                //),
                            });
                        });
					    
						if(form.gd_ls)
						{
							form.gd_ls.map((v) => {
							    v.set_gd_init.onoff_line_1.shop_address = v.address;
							    if (v.info) {
							        v.info.map((vs) => {
							            if (vs.img) {
							                vs.img = [
							                    {
							                        url: vs.img_url,
							                        urls: vs.img,
							                    },
							                ];
							            } else {
							                vs.img = [
							                    {
							                        url: "",
							                        urls: "",
							                    },
							                ];
							            }
							        });
							    }
							
							    if (
							        v.set_gd_init.onoff_line_1.bttn.type_2.qrcode1
							    ) {
							        v.set_gd_init.onoff_line_1.bttn.type_2.qrcode1 =
							            [
							                {
							                    url: v.set_gd_init.onoff_line_1.bttn
							                        .type_2.qrcode1_url,
							                    urls: v.set_gd_init.onoff_line_1
							                        .bttn.type_2.qrcode1,
							                },
							            ];
							    } else {
							        v.set_gd_init.onoff_line_1.bttn.type_2.qrcode1 =
							            [
							                {
							                    url: "",
							                    urls: "",
							                },
							            ];
							    }
							
							    if (
							        v.set_gd_init.onoff_line_1.bttn.type_2.qrcode2
							    ) {
							        v.set_gd_init.onoff_line_1.bttn.type_2.qrcode2 =
							            [
							                {
							                    url: v.set_gd_init.onoff_line_1.bttn
							                        .type_2.qrcode2_url,
							                    urls: v.set_gd_init.onoff_line_1
							                        .bttn.type_2.qrcode2,
							                },
							            ];
							    } else {
							        v.set_gd_init.onoff_line_1.bttn.type_2.qrcode2 =
							            [
							                {
							                    url: "",
							                    urls: "",
							                },
							            ];
							    }
							    if (!v.set_gd_init.onoff_line_1.week_use.week) {
							        v.set_gd_init.onoff_line_1.week_use.week = [];
							    }
							});
						}
                    }
					// setTimeout(()=>{
					this.updateGdInfo();
					// },1000)
                } else {
                    // 产品新建
                    this.setgoodList();
                    if (info.gd_ls) {
                        form.gd_ls.map((v, i) => {
                            info.gd_ls.map((vs, vi) => {
                                if (i == vi) {
                                    v.gd_name = vs.gdname;
                                    v.img = vs.img;
                                    v.max_unum = vs.max_unum;
                                    v.price = vs.price;
                                    v.price0 = vs.price0;
                                    v.qty = vs.qty;
                                }
                            });
                            v.mrxgradio =
                                !v.max_unum || v.max_unum == 0 ? 1 : 2;
                            v.tips = info.set_gd_init.onoff_line_1.tips;
                            v.set_gd_init.txt_gd = info.set_gd_init.txt_gd;
                            v.set_gd_init.onoff_line_1.shop_address =
                                info.set_gd_init.onoff_line_1.shop_address;
                        });
                    }
                }
                if (!info.chp_ls || info.chp_ls.length == 0) {
                    
                    this.setMscclist(this.msccselect);
                } else {
                    this.msccselect = info.chp_ls.length;
                    info.chp_ls.forEach(row => {
                        row.timeArr = [row.stime,row.etime]
                    })
                    form.chp_ls = info.chp_ls;
                    form.gd_ls.map((v, i) => {
                        v.mscccheckbox = [];
                        form.chp_ls.map((vs) => {
                            if (vs.gd_list) {
                                vs.gd_list.map((vw) => {
									if(!this.activeId)//创建活动
									{
										if(vw.gd_title == v.gd_title)//初始化时，没有gd_pos,只能对比产品名称
										{
											vs.chpno = "1";
											v.mscccheckbox.push(vs.chpno);//默认勾选
											vw.gd_pos = v.gd_pos;//初始值
										}
									}
									else
									{
										if (vw.gd_pos === v.gd_pos) 
										{
											v.mscccheckbox.push(vs.chpno);
											vw.gd_title = this.gdNameArr[Number(String(vw.gd_pos).substr(2,1))-1];//后端不愿意改，只能前端处理
										}
									}
                                });
                            }
                        });
                    });
                }
				
				console.log("form.chp_ls=========:",form.chp_ls);
                // 高级设置
                form.cpname = info.cpname;
                form.cpname2 = info.cpname2;

                form.ad_ls = Object.assign(form.ad_ls, info.ad_ls);
                form.ad_ls.is_time_long = form.ad_ls.time_long > 0 ? "1" : "2";
				
                if (form.ad_ls.img && form.ad_ls.img.length > 0) {
                    form.ad_ls.ad_length = form.ad_ls.img.length;
                    form.ad_ls.imgs = [];
                    form.ad_ls.img.map((v) => {
                        form.ad_ls.imgs.push({
                            img: [
                                {
                                    url: v.img_url,
                                    urls: v.img,
                                },
                            ],
                        });
                    });
                    form.ad_ls.img = form.ad_ls.imgs;
                    delete form.ad_ls.imgs;
                } else {
                    form.ad_ls.ad_length = 1;
                    form.ad_ls.img = [
                        {
                            img: [
                                {
                                    url: "",
                                    urls: "",
                                },
                            ],
                        },
                    ];
                }
                // if (param.hdongid) {
                //     info.set_advc.bttn_cpname = JSON.parse(
                //         info.set_advc.bttn_cpname
                //     );
                //     info.set_advc.bttn_main = JSON.parse(
                //         info.set_advc.bttn_main
                //     );
                //     info.set_advc.share = JSON.parse(info.set_advc.share);
                // }
                if (info.logo) {
                    this.qylogoradio = "2";
                    form.logo = [
                        {
                            url: info.logo_url,
                            urls: info.logo,
                        },
                    ];
                } else {
                    form.logo = [
                        {
                            url: "",
                            urls: "",
                        },
                    ];
                }

                if (info.loading) {
                    this.ymjztpradio = "2";
                    form.loading = [
                        {
                            url: info.loading_url,
                            urls: info.loading,
                        },
                    ];
                } else {
                    form.loading = [
                        {
                            url: "",
                            urls: "",
                        },
                    ];
                }

                // info.set_advc.bttn_main.type_1.type_2 = {
                //     link: info.set_advc.bttn_main.type_1.type_2 || "",
                // };

                if (info.set_advc.bttn_main.type_2.qrcode1) {
                    info.set_advc.bttn_main.type_2.qrcode1 = [
                        {
                            url: info.set_advc.bttn_main.type_2.qrcode1_url,
                            urls: info.set_advc.bttn_main.type_2.qrcode1,
                        },
                    ];
                } else {
                    info.set_advc.bttn_main.type_2.qrcode1 = [
                        {
                            url: "",
                            urls: "",
                        },
                    ];
                }

                if (info.set_advc.bttn_main.type_2.qrcode2) {
                    info.set_advc.bttn_main.type_2.qrcode2 = [
                        {
                            url: info.set_advc.bttn_main.type_2.qrcode2_url,
                            urls: info.set_advc.bttn_main.type_2.qrcode2,
                        },
                    ];
                } else {
                    info.set_advc.bttn_main.type_2.qrcode2 = [
                        {
                            url: "",
                            urls: "",
                        },
                    ];
                }

                if (info.set_advc.share.img) {
                    this.fxtbradio = "2";
                    info.set_advc.share.img = [
                        {
                            url: info.set_advc.share.img_url,
                            urls: info.set_advc.share.img,
                        },
                    ];
                } else {
                    info.set_advc.share.img = [
                        {
                            url: "",
                            urls: "",
                        },
                    ];
                }
                if (info.set_advc.share.txt) {
                    this.fxnrradio = "2";
                }
                form.set_advc = info.set_advc;
                form.ad_ls.ismust = String(info.ad_ls.ismust);
                form.ad_ls.stype = String(info.ad_ls.stype);
                form.ad_ls.ismusic = String(info.ad_ls.ismusic);
			    
				form.ismusic = info.ismusic;
				form.music_url = info.music_url;
				
                form.iscpname2 = String(info.iscpname2);
                form.isad = String(info.isad);
                form.isit = String(info.isit);
                form.set_advc.bttn_cpname.type = String(
                    form.set_advc.bttn_cpname.type
                );
                form.set_advc.bttn_cpname.type_3.shopid_yd =
                    form.set_advc.bttn_cpname.type_3.shopid_yd == 0
                        ? ""
                        : String(form.set_advc.bttn_cpname.type_3.shopid_yd);
                form.set_advc.bttn_main.type = String(
                    form.set_advc.bttn_main.type
                );
                form.set_advc.share.isopen = String(form.set_advc.share.isopen);
                form.set_advc.share.is2quan = String(
                    form.set_advc.share.is2quan
                );
                form.set_advc.bttn_main.type_1.typeto = String(
                    form.set_advc.bttn_main.type_1.typeto
                );
                form.set_advc.bttn_main.type_2.typeto = String(
                    form.set_advc.bttn_main.type_2.typeto
                );
				
				let fBtnObj = {};
				fBtnObj.act = this.active_act.editFlowBtnContext;
				let fType = form.set_advc.bttn_main.type;
				let bttname = form.set_advc.bttn_main['type_'+fType] ? form.set_advc.bttn_main['type_'+fType].bttname : "功能按钮未开启";
				fBtnObj.data = bttname;
				editInterActive.update(fBtnObj);
				
                if (this.activeId) {
                    let arr = [this.active_act.editActiveTitle];
                    for (let i = 0; i < arr.length; i++) {
                        this.sendoutEidt(arr[i]);
                    }
                }
				
				
				
				//活动说明初始化
				form.set_more.info_page = info.set_more.info_page;
				this.setMoreData();
				
				// if(!this.activeId) //创建活动
				// {
				// 	let cObj = {};
				// 	cObj.act = this.active_act.creatorActive;
				// 	cObj.data = form;
				// 	editInterActive.update(cObj);
				// }
				if(info.set_skin)
				{
					if(!info.set_skin.gdListDeatail)
					{
						form.set_skin.gdListDeatail = [];
						form.gd_ls.forEach((s)=>{
							let obj = {};
							obj.gd_pos = s.gd_pos;
							obj.follow = {
								color: "#FFF", //字体颜色
							    bgColor: "#3388FF"//背景颜色
							}, 
						    form.set_skin.gdListDeatail.push(obj)
						});
					}
				}
				
				if(form.set_skin)
				{
					
					let sObj = {};
					sObj.act = this.active_act.updateSkin;
					sObj.data = form.set_skin;
					editInterActive.update(sObj);
				}
            }
			// setTimeout(()=>{
			if(this.activeId)
			{
				this.sendoutEidt(this.active_act.edidShareImg); //分享图片初始化
				this.sendoutEidt(this.active_act.edidShareContext); //分享文字初始化
			}
			// },1100);
        },
		
		setMoreData()
		{
			const form = this.form;
			form.set_more.info_page.forEach((s)=>{
				if(s.code == 'info_gd')
				{
					if(s.type == 1)
					{
						s.txt = "";
						form.gd_ls.forEach((g,i)=>{
							if(s.txt == "")
							{
								s.txt = this.gdNameArr[i] + ": " + g.gd_name;
							}
							else
							{
								s.txt = s.txt + "\n" + this.gdNameArr[i] + ": " + g.gd_name;
							}
						});
					}
				}
				if(s.code == 'info_time'){
					if(form.chp_ls && form.chp_ls[0])
					{
						s.txt = form.chp_ls[0].stime;
					}
				}
				if(s.code == 'info_cpname'){
					s.txt = form.cpname;
				}
				if(s.code == 'info_cpname2'){
					s.txt = form.cpname2;
					s.iscpname2 = form.iscpname2;
				}
				if(s.code == 'info_it'){
					s.isit = form.isit;
				}
				if(s.code == 'info_txt')
				{
					s.info_txt = form.info_txt;
				}
			});
			let setMore = {};
			setMore.act = this.active_act.edidDescripTxtContext;
			setMore.data = form.set_more.info_page;
			editInterActive.update(setMore);
		},
		
		onScroll(e)
		{
			
		},
		
		jump()
		{
			if(document && document.querySelector('#' + this.highlight_i))
			{
				document.querySelector('#' + this.highlight_i).scrollIntoView({
					block: 'center',
					behavior: 'smooth'
				})
			}
		},
    },
};
</script>
